<?php

require_once("includes/global.inc");

/* Connect using SQL Server Authentication. */
$conn = sqlsrv_connect( $server_name, $connectionInfo);
if( $conn === false )
{
     echo "Unable to connect.<br/>";
     die( print_r( sqlsrv_errors(), true));
} else 
	echo "connection is successfully<br/>";

/* Set up and execute the query. */
$tsql = "SELECT TOP 100 [IDX_ID],[TERM]
         FROM [marc_stud].[dbo].[IDX100q]";
$stmt = sqlsrv_query( $conn, $tsql);
if( $stmt === false)
{
    echo "marc_stud is not enable<br/>";
    die( print_r( sqlsrv_errors(), true));
}

echo "marc_stud is enable, sample output:<br/><br/>";
/* Retrieve each row as an associative array and display the results.*/
while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC))
{
    echo $row['TERM'].", ".$row['IDX_ID']."\n";
}

/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $conn);
